package com.ran.java_gobang_new.pojo.response;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-09-02
 * Time: 23:21
 */
@Data
public class Result {
    private Integer code; // 200 为成功, 400为失败, 401为未登录
    private String message;
    private Object data;

    // 成功
    public static Result success(Object data, String message) {
        Result result = new Result();
        result.setCode(200);
        result.setData(data);
        result.setMessage(message);
        return result;
    }

    // 成功
    public static Result success(String message) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage(message);
        return result;
    }

    // 成功
    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setData(data);
        return result;
    }

    // 未登录
    public static Result unLogin(String message) {
        Result result = new Result();
        result.setCode(401);
        result.setMessage(message);
        return result;
    }

    // 失败
    public static Result fail(Object data, String message) {
        Result result = new Result();
        result.setCode(400);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    // 失败
    public static Result fail(String message) {
        Result result = new Result();
        result.setCode(400);
        result.setMessage(message);
        return result;
    }
}
